package com.example.smartauctionserver;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;

public class AddProductActivity extends Activity {

	private String mProName;
	private String mProInitPrice;
	private String mProDes;

	private EditText etProName;
	private EditText etProInitPrice;
	private EditText etProDes;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_product);

		etProName = (EditText) findViewById(R.id.ProName);
		etProInitPrice = (EditText) findViewById(R.id.ProInitPrice);
		etProDes = (EditText) findViewById(R.id.ProDes);

		etProDes.setOnKeyListener(new OnKeyListener() {
			
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if(keyCode == KeyEvent.KEYCODE_ENTER)
					BtnClick(null);
				return false;
			}
		});


	}

	public void BtnClick(View arg0) {

		mProName = etProName.getText().toString();
		mProInitPrice = etProInitPrice.getText().toString();
		mProDes = etProDes.getText().toString();

		/*
		 * edittext should be filled with appropriate data. handle error
		 */
		Intent intent = new Intent(AddProductActivity.this,
				BiddingActivity.class);
		intent.putExtra("proName", mProName);
		intent.putExtra("proPrice", mProInitPrice);
		intent.putExtra("proDes", mProDes);
		startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_add_product, menu);
		return true;

	}

}